// ++++++++++++++++++++++++++++++++++++++++
// 《零基础Go语言算法实战》源码
// ++++++++++++++++++++++++++++++++++++++++
// Author:廖显东（ShirDon）
// Blog:https://www.shirdon.com/
// Gitee:https://gitee.com/shirdonl/goAlgorithms.git
// Buy link :https://item.jd.com/14101229.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import "fmt"

type TreeNode struct {
	Data  int
	Left  *TreeNode
	Right *TreeNode
}

func searchBST(root *TreeNode, data int) *TreeNode {
	if root == nil {
		return nil
	}
	if root.Data == data {
		return root
	} else if root.Data < data {
		return searchBST(root.Right, data)
	} else {
		return searchBST(root.Left, data)
	}
}

func main() {
	treeNode := TreeNode{6, &TreeNode{5, nil, nil}, &TreeNode{3, nil, nil}}
	res := searchBST(&treeNode, 0)
	fmt.Println(res)
}
